package com.fangyi.yunmusic.controller;

import com.fangyi.yunmusic.pojo.front.end.FEAlbumVO;
import com.fangyi.yunmusic.service.AlbumService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class AlbumController {
    @Autowired
    private AlbumService albumService;

    /**
     * 获取歌手的专辑
     * @param artistId
     * @param page
     * @param pageSize
     * @return
     */
    @GetMapping("/artist/album")
    public Object getArtistAlbum(String artistId,Integer page,Integer pageSize){
        return albumService.selectAlbumVO(artistId,page,pageSize);
    }

    @GetMapping("/album/all")
    public Object getAlbum(Integer page, Integer pageSize) {
        return albumService.selectAlbum(page, pageSize);
    }

    /**
     * 获取专辑详细信息
     * @param albumId
     * @return
     */
    @GetMapping("/album")
    public Object getAlbumDetail(String albumId){
        return albumService.getAlbumDetailVO(albumId);
    }

    /**
     * 新增专辑
     * @param artistId
     * @param name
     * @param description
     * @return
     */
    @PostMapping("/album/publish")
    public Object publishAlbum(String artistId, String name,String description,String picUrlId){
        albumService.insertAlbum(artistId,new FEAlbumVO(name,description,picUrlId));
        return "OK";
    }

    /**
     * 删除专辑
     * @param albumId
     * @return
     */
    @PostMapping("/album/delete")
    public Object deleteAlbum(String albumId){
        albumService.deleteAlbum(albumId);
        return "OK";
    }

    @GetMapping("/album/count")
    public Object getAlbumCount(){
        return albumService.getAlbumCount();
    }
}
